﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Panel_Character : BasePanel
{
    CanvasGroup canvas;

    public Animator animator;
    public Text textMoney;
    public Text textSkinNum;

    private void Awake()
    {
        canvas = GetComponent<CanvasGroup>();
    }

    public override void OnEnter()
    {
        base.OnEnter();
        gameObject.SetActive(true);
        UpdatePanelData();
    }
    public override void OnExit()
    {
        base.OnExit();
        gameObject.SetActive(false);
        User.instance.SkinDataSave();
    }
    public override void OnPause()
    {
        base.OnPause();
        canvas.alpha = 0;
        canvas.blocksRaycasts = false;
    }
    public override void OnResume()
    {
        base.OnResume();
        canvas.alpha = 1;
        canvas.blocksRaycasts = true;
        UpdatePanelData();
    }

    /// <summary>
    /// 背景的旋转效果
    /// </summary>
    public GameObject VFX;
    private float spd = -40;

    private void Update()
    {
        VFX.transform.Rotate(0, 0, spd * Time.deltaTime);

      
        if (Input.GetButtonDown("Cancel"))
        {
            GameControl.instance.GameOver();
            UIManager.Instance.PopPanel();
        }
        
    }

    public void ClosePanel()
    {
        UIManager.Instance.PopPanel();
    }

    /// <summary>
    /// 更新皮肤界面的游戏数据，如金币等
    /// </summary>
    public void UpdatePanelData()
    {
        textMoney.text = User.instance.Money.ToString();
        textSkinNum.text = User.instance.SkinsHadNum + "/" + User.instance.SkinsAllNum;
    }




}
